<?php
include('config.php');
include('fonctions.php');
$connection = connexionBdd();

$return_arr = array();


$q = strtoupper(htmlentities($_REQUEST['term'])). '%'; // protection
//$q='anz%';
$req = $connection->prepare('SELECT `nom_ville` FROM `villes` WHERE `nom_ville_maj` LIKE :ville LIMIT 0, 10');
$req->bindParam(':ville', $q, PDO::PARAM_STR);
$req->execute();

while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) {    
    $row_array['label'] = $donnees['nom_ville'];
    array_push($return_arr,$row_array);


}

$req->closeCursor();
echo json_encode($return_arr);
//echo '<pre>';
//print_r($GLOBALS);
//echo '</pre>';
?>